/* Message List */
// a.k.a. notifications in the menu

// main list
.message-list {
  width: 29em;
  padding: 0;
  color: $secondary_fg_color;
  text-shadow: none;
  box-shadow: none;
  border: 0 solid $border_color;

  // padding and margins to account for scrollbar
  &:ltr {
    margin-left: $container_padding;
    margin-right: 0;
    padding-right: $container_margin;
    border-right-width: 1px;
  }

  &:rtl {
    margin-right: $container_padding;
    margin-left: 0;
    padding-left: $container_margin;
    border-left-width: 1px;
  }

  .message-list-placeholder {
    @extend %title_2;
    color: $disabled_secondary_fg_color;

    // icon size and color
    > StIcon {
      icon-size: 96px; // 48px
      margin-bottom: $container_margin * 3;
      -st-icon-style: symbolic;
    }
  }
}

.message-view {
  // to account for scrollbar
  &:ltr { margin-right: $container_padding * 2; }
  &:rtl { margin-left: $container_padding * 2; }

  -st-vfade-offset: 68px;

  .message {
    margin-bottom: $container_padding * 2 !important;
  }
}

// do-not-disturb + clear button
.message-list-controls {
  // NOTE: remove the padding if notification_bubble could remove margin for drop shadow
  padding: $container_padding * 2;
  padding-bottom: $container_padding;
  spacing: $container_padding;
  @extend %heading;
    .dnd-button {
    // We need this because the focus outline isn't inset like for the buttons
    // so the dnd button would grow when it gets focus if we didn't change only
    // its color when focusing.
    border-width: 2px;
    border-color: transparent;
    border-radius: 32px;
    border-style: solid;

    &:focus {
      border-color: transparentize($primary_color, 0.4);
    }
  }
}

// message notification group
.message-notification-group {
  spacing: $container_padding * 2;

  .message-group-header {
    padding: $container_padding;
    .message-group-title {
      @extend %title_2;
      margin: 0 $container_margin;
    }
  }

  // close button
  .message-collapse-button {
    @extend .icon-button;
    color: $fg_color;
    background-color: transparentize($fg_color, 0.8);
    padding: 4px;
    &:hover { background-color: transparentize($fg_color, 0.7); }
    &:active { background-color: transparentize($fg_color, 0.8); }
  }
}

// message bubbles
.message {
  background-color: $base_color;
  border-radius: $buttons_radius;
  color: $secondary_fg_color;
  text-shadow: none;
  padding: 0;
  margin: $container_margin;
  box-shadow: 0 3px 8px -2px rgba(black, 0.15);
  background-color: rgba($base_color, 0.95);
  border: 1px solid transparent;
  border-left: none;
  border-bottom: none;

  &:hover, &:focus, &:active { background-color: $base_color; }

  .popup-menu & {
    margin: 0 0 $container_margin;
    box-shadow: none;
    background-color: $card_bg_color;
    border-radius: $buttons_radius;
    color: $secondary_fg_color;
    border: 1px solid $popover_button_border;

    &:hover, &:focus {
      background-color: $card_hover_color;
      border-color: if($variant == 'light', rgba(black, 0.15), rgba(white, 0.08));
      box-shadow: none;
    }
  
    &:active {
      background-color: $card_active_color;
      box-shadow: none;
    }
  }

  &:second-in-stack {
    background-color: if($variant == 'light', darken($card_bg_color, 4%), lighten($card_bg_color, 2%));
    box-shadow: none;
  }

  &:lower-in-stack {
    background-color: if($variant == 'light', darken($card_bg_color, 7%), lighten($card_bg_color, 4%));
    box-shadow: none;
    border-color: $popover_button_border; // a not ideal workaround for light theme
  }

  // message header
  .message-header {
    padding: 0 $scaled_padding;
    spacing: $container_padding;
    color: $disabled_fg_color;

    // remove side padding to accommodate the close button
    &:ltr { padding-right: 0; }
    &:rtl { padding-left: 0; }

    // header source icon
    .message-source-icon {
      icon-size: $scalable_icon_size; // 16px
      -st-icon-style: symbolic;
    }

    // box that contains the source icon, source name and timestamp of the message
    .message-header-content {
      spacing: $container_padding;
      min-height: to_em(24px);
      padding-bottom: $container_padding;

      // header source title
      .message-source-title {
        font-weight: bold;
      }

      // Time label
      .event-time {
        @extend %caption;
        color: $disabled_fg_color;
        // Add bottom padding to align the app name with the time horizontally
        padding-bottom: to_em(1px);

        &:ltr { text-align: right; }
        &:rtl { text-align: left; }
      }
    }

    // buttons in the message header
    .message-expand-button,
    .message-close-button {
      @extend .icon-button;
      color: $fg_color;
      background-color: transparentize($fg_color, .9);
      padding: 4px;
      &:hover { background-color: transparentize($fg_color, .81);}
      &:active,
      &:active:hover { background-color: transparentize($fg_color, .76);}
      &:insensitive { background-color: transparentize($fg_color, .93);}
    }

    .message-expand-button {
      padding: 4px;
      &:ltr { margin-right: 0; }
      &:rtl { margin-left: 0; }
    }
  }

  // container for message contents
  .message-box {
    padding: $container_padding;
    margin: $container_padding;
    margin-top: 0;
    spacing: $container_padding;

    // icon of the message
    .message-icon {
      &:ltr { margin-right:$container_padding; }
      &:rtl { margin-left:$container_padding; }

      // icon size and color
      icon-size: $base_icon_size * 3; // 48px
      -st-icon-style: symbolic;

      &.message-themed-icon {
        border-radius: $circular_radius; // is circular
        background-color: transparentize($fg_color, 0.8);
        icon-size: $base_icon_size;
        min-width: $base_icon_size * 3;
        min-height: $base_icon_size * 3;
      }
    }

    // If the header isn't displayed we need more top margin
    &:first-child {
      margin-top: $container_padding * 2;
    }

    // text of the message
    .message-content {
      spacing: $container_margin;

      // message title
      .message-title {
        font-weight: bold;
      }
    }
  }
}

// URLs in messages
.url-highlighter {
  link-color: $link_color;
}

/* Media Controls */
.message-media-control {
  margin: 4px 0;
  padding: 0 $container_padding * 2;
  border-radius: $circular_radius;
  color: $secondary_fg_color;
  border: none;

  &:hover, &:focus { color: $fg_color; background-color: $divider_color; }
  &:active { color: $fg_color; background-color: $track_color; }
  &:insensitive { color: $disabled_secondary_fg_color; }

  & StIcon { icon-size: $base_icon_size; }
}

.media-message {
  // album-art
  .message-icon {
    border-radius: $buttons_radius !important;

    &.message-themed-icon {
      icon-size: $large_icon_size !important; // 32px
    }
  }
}
